/**
 * 账单相关API服务
 */

const http = require('./http');

/**
 * 添加账单
 * @param {Object} data 账单数据 {coupleId, amount, category, description, billTime}
 * @returns {Promise} Promise对象
 */
const addBill = (data) => {
  return http.post('/api/bills', data);
};

/**
 * 获取情侣账单列表
 * @param {Number} coupleId 情侣关系ID
 * @param {Object} params 查询参数 {startDate, endDate, category}
 * @returns {Promise} Promise对象
 */
const getCoupleBills = (coupleId, params = {}) => {
  return http.get(`/api/couples/${coupleId}/bills`, params);
};

/**
 * 获取账单详情
 * @param {Number} id 账单ID
 * @returns {Promise} Promise对象
 */
const getBillDetail = (id) => {
  return http.get(`/api/bills/${id}`);
};

/**
 * 更新账单
 * @param {Number} id 账单ID
 * @param {Object} data 账单数据 {amount, category, description}
 * @returns {Promise} Promise对象
 */
const updateBill = (id, data) => {
  return http.put(`/api/bills/${id}`, data);
};

/**
 * 删除账单
 * @param {Number} id 账单ID
 * @returns {Promise} Promise对象
 */
const deleteBill = (id) => {
  return http.del(`/api/bills/${id}`);
};

/**
 * 获取账单统计
 * @param {Number} coupleId 情侣关系ID
 * @param {Object} params 查询参数 {month}
 * @returns {Promise} Promise对象
 */
const getBillSummary = (coupleId, params = {}) => {
  return http.get(`/api/couples/${coupleId}/bills/summary`, params);
};

/**
 * 获取账单类别列表
 * @returns {Promise} Promise对象
 */
const getBillCategories = () => {
  return http.get('/api/bills/categories');
};

module.exports = {
  addBill,
  getCoupleBills,
  getBillDetail,
  updateBill,
  deleteBill,
  getBillSummary,
  getBillCategories
};